﻿#include"User_Input.h"

/// <summary>
/// 申请获取学生信息并生成结点
/// </summary>
/// <returns>学生信息结构体指针</returns>
Stu_Info* get_stu_info() {
	//新建学生结点
	Stu_Info* s = (Stu_Info*)malloc(sizeof(Stu_Info));
	assert(s != NULL);
	printf("> 输入学生学号：");
	scanf_s("%d", &s->id);
	printf("> 输入学生性别(男/女)：");
	scanf_s("%s", s->gender,3);
	//fgets(s->gender, 3, stdin);//另一种获取方式
	printf("> 输入学生姓名：");
	scanf_s("%s", s->name, NAME_SIZE);
	return s;
}

/// <summary>
/// 申请获取成绩信息并生成结点
/// </summary>
/// <returns>成绩结构体指针</returns>
Score_Info* get_score_info() {
	//申请成绩信息结点空间
	Score_Info* s = (Score_Info*)malloc(sizeof(Score_Info));
	assert(s != NULL);
	printf("> 继续输入学生成绩：\n");
	printf("------语文：");
	scanf_s("%f", &s->chinese_data);
	printf("------数学：");
	scanf_s("%f", &s->math_data);
	printf("------英语：");
	scanf_s("%f", &s->english_data);
	printf("------DONE!\n\n");
	s->average = (s->chinese_data + s->english_data + s->math_data) / CURSORS_NUM;	//处理其他数据
	s->isPass = ' ';	//设置不及格标志位
	if (s->chinese_data < 60) {
		s->isPass = s->is_ch_pass = '*';
	}
	else {
		s->is_ch_pass = '|';
	}
	if (s->math_data < 60) {
		s->isPass = s->is_math_pass = '*';
	}
	else {
		s->is_math_pass = ' ';
	}
	if (s->english_data < 60) {
		s->isPass = s->is_en_pass = '*';
	}
	else {
		s->is_en_pass = ' ';
	}
	//设置默认rank
	s->rank = 1;
	return s;
}